﻿using UnityEngine;
using System.Collections;

namespace MiniGameTrash
{
    public class SampahScript : MonoBehaviour
    {
        Transform trash;
        bool move;
        float startTime, distance;

        // Use this for initialization
        void Start()
        {

        }

        // Update is called once per frame
        void Update()
        {
            /*RaycastHit2D click = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero);

            if (Input.GetMouseButtonUp(0))
            {
                trash = GameObject.Find("Tempat Sampah Organik").transform;
                move = true;
                startTime = Time.time;
                distance = Vector2.Distance(this.transform.position, trash.position);
            }

            if (Input.GetMouseButtonUp(1))
            {
                trash = GameObject.Find("Tempat Sampah NonOrganik").transform;
                move = true;
                startTime = Time.time;
                distance = Vector2.Distance(this.transform.position, trash.position);
            }

            if (move)
            {
                float progress = ((Time.time - startTime) * 0.2f) / distance;
                this.transform.position = Vector2.Lerp(transform.position, trash.position, progress);
            }*/
        }

        void OnTriggerEnter2D(Collider2D collider)
        {
            if (collider.tag == "Trash Can")
            {
                Destroy(gameObject);
            }
        }
    }
}